package ru.amse.baltijsky.javascheme.tree;

/**
 * A node for the syntactic construction that changes normal program flow, ie. does not give it directly to the
 * next (in the sequential sense) construction in the code. Examples: break, continue, throw, return.
 * This is a marker interface and represents only a logical differentiation of the nodes that change program flow.
 */
public abstract class FlowChangeNode extends SchemaNode {
    /**
     * The node to which the program flow jumps.
     * <code>null</code> if the jump is not local, ie. goes out of the method scope.
     */
    private SchemaNode nodeToJump = null;

    protected FlowChangeNode() {
    }

    protected FlowChangeNode(SchemaNode parentNode, SchemaNode prevNode) {
        super(parentNode, prevNode);
    }

    protected FlowChangeNode(SchemaNode parentNode, SchemaNode prevNode, String[] s) {
        super(parentNode, prevNode, s);
    }

    protected FlowChangeNode(String[] s) {
        super(s);
    }

    public SchemaNode getNodeToJump() {
        return nodeToJump;
    }

    public void setNodeToJump(SchemaNode nodeToJump) {
        this.nodeToJump = nodeToJump;
    }

    @Override
    public <T, C, E extends Throwable> T accept(TreeVisitor<T, C, E> visitor, C context) throws E {
        return visitor.visit(this, context);
    }
}
